﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using Newtonsoft.Json;

namespace TRPOP.CMS.Web.Admin
{
    public partial class content_header : BaseAdmin
    {
        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_SubPagePermission = Plugin.PermissionKeys.PermissionEnum.Content_AllControl;
        }
        #endregion

        #region 页面变量
        protected bool m_IsAdd = true;
        protected int m_intNId = 0;
        protected int m_intId = 0;
        protected string m_strParentName = "";
        protected string m_strNodeName = "";
        protected NodeInfo m_NodeInfo = new NodeInfo();
        protected NodeInfo m_InheritNodeInfo = new NodeInfo();
        protected NodeManage m_NodeManage = new NodeManage();

        protected string m_strAction = "";
        protected int m_intRecordCount = 0;
        protected int m_intContentId = 0;
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            m_intNId = RequestHelper.RequestInt("nodeid");
            m_intContentId = RequestHelper.RequestInt("contentid");

            if (!IsPostBack)
            {
                LoadBase();
                BindData();
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {


        }

        protected void lbtnDelete_Click(object sender, EventArgs e)
        {
            LinkButton lbtn = (LinkButton)sender;
            //lbtn.CommandArgument.ToString().Split("|")[0];
            int intExtendId = lbtn.CommandArgument.ToString().Split('|')[0].ToInt();
            string strExtendTableName = lbtn.CommandArgument.ToString().Split('|')[1];
            SubmitAlertDelete((new ContentManage()).DeleteInfoByExtendId(intExtendId, strExtendTableName));//删除基表信息，并且删除扩展表信息
            LoadBase();
        }
        #endregion

        #region 页面方法

        public void LoadBase()
        {
            if (m_intNId > 0)
            {

                m_NodeInfo = m_NodeManage.GetInfoById(m_intNId);
                if (m_NodeInfo != null && m_NodeInfo.IsHidde == false)
                {
                    m_strNodeName = "[" + m_NodeInfo.Name + "]";
                    if (m_NodeInfo.NodeTypeId == (int)NodeType.EnumElement.VirualNode)
                    {
                        m_InheritNodeInfo = m_NodeManage.GetInfoById(m_NodeInfo.InheritNodeID);
                    }
                    // rptList.DataSource = (new ContentManage()).GetListByPager(Pager.CurrentPage, Pager.PageSize, " and NodeId=" + m_intNId, " EliteWeight desc,TopWeight desc", out m_intRecordCount);
                    // rptList.DataBind();
                    //Pager.RecordCount = m_intRecordCount;
                }
                else
                {
                    m_NodeInfo = new NodeInfo();
                    base.Redirect("../error.aspx?msg=结点不存在了");
                }
            }
            else
            {
                base.Redirect("../error.aspx?msg=参数不正确");
            }
        }

        public void BindData()
        {


        }


        #endregion
    }
}